define(function(require, exports){
	var $ = require('jquery');
	var pubjs = require('pubjs');
	var grid = require('@base/highGrid');
	var util = require('util');
	var tip = require('@base/tip');
	var popwin	= require('@base/dialog').base;

	var Base = popwin.extend({
		init:function(config){
			config = pubjs.conf(config, {
				'title': LANG('素材组列表'),
				'width': 700,
				'showFoot': true,
				'param': null,
				'silence': false,
				'size': 'm'
			});

			this.$selected = {};
			this.Super('init', arguments);
		},
		afterBuild:function() {
			this.Super('afterBuild', arguments);
			var target = this.getContainer('body');
			target.append(
				`
					<div class="">
						<div pub-name="grid" pub-mod="materialGroup/grid/list.base"></div>
					</div>
				`
			);

			this.buildFromTemplate({
				grid: {
					hasBatch: false,
					hasDetail: false,
					hasMenu: false,
					hasSearch: false,
					hasSelect: false,
					cols: [
						{name:'_id',text:"ID", sort: true, width: 60, align: 'center'},
						{name:'Name', text: LANG("名称"), width: 150, align: 'center'},
						{name:'StrategyInfo', text: LANG("创意包落地页"), width: 200, render: 'renderStrategy', align: 'center'},
						{name:'UpdateTime', text: LANG("更新时间"), width: 150, render: 'renderTime', align: 'center'},
						{name:'op',text: LANG("操作"), type: 'op', render: this.renderOperate, align: 'center'}
					]
				}
			});
		}
		,renderOperate: function(i, val, row) {
			if (this.$selected[row._id])
			{
				return '<button data-op="unselect" class="btn btn-success">' + LANG('取消') + '</button>';
			}
			else
			{
				return '<button data-op="select" class="btn btn-default">' + LANG('添加') + '</button>';
			}
		}
		,setParam: function(param) {
			this.$.grid.setParam(param);
			return this;
		}
		,load: function () {
			this.$.grid.load();
			return this;
		}
		,show: function() {
			this.Super('show', arguments);
			this.$.grid.reset().load();
			return this;
		}
		,reset: function () {
			this.$selected = {};
			return this;
		}
	});

	exports.base = Base;
});